package com.portal.tag;

import java.io.IOException;

import javax.portlet.PortletResponse;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

import com.portal.util.constants.TagConstants;

public class NamespaceTag extends TagSupport {

  private static final long serialVersionUID = 286L;

  public int doStartTag() throws JspException {
    PortletResponse portletResponse = (PortletResponse) pageContext.getRequest().getAttribute(TagConstants.PORTLET_RESPONSE);
    String namespace = portletResponse.getNamespace();
    JspWriter writer = pageContext.getOut();

    try {
      writer.print(namespace);
    } catch (IOException ioe) {
      throw new JspException("Unable to write namespace", ioe);
    }

    return SKIP_BODY;
  }
}
